package zx.x.modules.app.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import zx.x.modules.app.entity.JqjsEntity;
import zx.x.modules.app.entity.YwglEntity;
import zx.x.modules.app.service.JqjsService;
import zx.x.common.utils.PageUtils;
import zx.x.common.utils.R;
import zx.x.modules.common.entity.CreativeGoodsEntity;


/**
 * 
 *
 * @author x
 * @email x
 * @date 2023-09-12 17:52:21
 */
@RestController
@RequestMapping("/app/jqjs")
public class JqjsController {
    @Autowired
    private JqjsService jqjsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(JqjsEntity jq){
        QueryWrapper<JqjsEntity> queryWrapper = new QueryWrapper<JqjsEntity>();
        queryWrapper.eq("delete_flag","0").eq("sfsj","1").select(JqjsEntity.class, info -> !info.getColumn().equals("text"));
        Page page = PageHelper.startPage(jq.getPage(),jq.getLimit());
        List<JqjsEntity> list = jqjsService.list(queryWrapper);
        return R.ok().put("page", list).put("pages",page.getPages()).put("total",page.getTotal());
    }

    /**
     * 首页下边那个列表
     */
    @RequestMapping("/syList")
    public R syList(JqjsEntity jq){
        QueryWrapper<JqjsEntity> queryWrapper = new QueryWrapper<JqjsEntity>();
        queryWrapper.eq("delete_flag","0").eq("sfsj","1").eq("sfzs","1").select(JqjsEntity.class,info -> !info.getColumn().equals("text"));
        Page page = PageHelper.startPage(jq.getPage(),jq.getLimit());
        List<JqjsEntity> list = jqjsService.list(queryWrapper);
        return R.ok().put("page", list).put("pages",page.getPages()).put("total",page.getTotal());
    }


    /**
     * 信息
     */
    @RequestMapping("/info")
    public R info(Integer id){
		JqjsEntity jqjs = jqjsService.getById(id);

        return R.ok().put("jqjs", jqjs);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody JqjsEntity jqjs){
		jqjsService.save(jqjs);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody JqjsEntity jqjs){
		jqjsService.updateById(jqjs);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(Integer[] ids){
		jqjsService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
